"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.transferFileSize = void 0;
// 处理文件大小的显示
var BYTE_PER_KB = 1024;
var BYTE_PER_MB = 1024 * 1024;

var transferFileSize = function transferFileSize(fileSize) {
  // 非数字类型直接展示，数字类型需要折算
  if (typeof fileSize !== 'number') {
    return fileSize;
  }

  if (fileSize >= BYTE_PER_MB) {
    return "".concat(parseFloat((fileSize / BYTE_PER_MB).toFixed(2)), " MB");
  }

  if (fileSize >= BYTE_PER_KB) {
    return "".concat(parseFloat((fileSize / BYTE_PER_KB).toFixed(2)), " KB");
  }

  return "".concat(fileSize, " B");
};

exports.transferFileSize = transferFileSize;